package com.miyake.loveviewweb.client.chart;

import com.google.appengine.api.datastore.Key;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.miyake.loveviewweb.client.DataServiceWrapper;
import com.miyake.loveviewweb.shared.model.ChartModel;

public class ChartSizeUpdater {
    void onComplete(ChartModel chartModel) {};
    
    public ChartSizeUpdater(final Key key, Integer width, Integer height) {
        DataServiceWrapper.getInstance().getService().updateChartSize(key, width, height, new AsyncCallback<Void>() {

            public void onFailure(Throwable caught) {

            }

            public void onSuccess(Void result) {
                DataServiceWrapper.getInstance().getService().getChart(key, true, new AsyncCallback<ChartModel>() {

                    public void onFailure(Throwable caught) {
                        // TODO Auto-generated method stub
                        
                    }

                    public void onSuccess(ChartModel result) {
                        onComplete(result);
                    }
                    
                });
            }
            
        });
    }
}
